package com.xuanwei.search.entity.index;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * @Author jiangyong
 * @Description TODO
 * @Date 2019/6/27 17:48
 **/
@Document(indexName = "xw_product",type = "type_product")
@Data
public class ProductIndex {

    @Id
    private Integer id;

    @Field(type= FieldType.Text,store = true,analyzer = "ik_max_word",searchAnalyzer = "ik_max_word")
    private String name;

    @Field(type = FieldType.Integer)
    private Integer source;

    @Field(type = FieldType.Keyword)
    private String productNo;


    /**
     * 轮播图,多张以逗号隔开
     */
    @Field(type = FieldType.Keyword)
    private String bannerImage;

    /**
     * 商品主图
     */
    @Field(type = FieldType.Keyword)
    private String mainImage;

    /**
     * 市场价或原价
     */
    @Field(type = FieldType.Keyword)
    private String marketPrice;

    /**
     * 最大市场价
     */
    @Field(type = FieldType.Double)
    private BigDecimal maxMarketPrice;

    /**
     * 最小市场价
     */
    @Field(type = FieldType.Double)
    private BigDecimal minMarketPrice;

    /**
     * 最小价格
     */
    @Field(type = FieldType.Double)
    private BigDecimal minPrice;

    /**
     * 最大价格
     */
    @Field(type = FieldType.Double)
    private BigDecimal maxPrice;

    /**
     * 现价
     */
    @Field(type = FieldType.Keyword)
    private String price;

    /**
     * 库存
     */
    @Field(type = FieldType.Integer)
    private Integer stock;

    /**
     * 目录ID,以-隔开
     */
    @Field(type = FieldType.Integer)
    private Integer categoryId;

    /**
     * 目录名称
     */
    @Field(type = FieldType.Keyword)
    private String categoryName;

    /**
     * 销售量
     */
    @Field(type = FieldType.Integer)
    private Integer saleNum;

    /**
     * 商品详情
     */
    @Field(type = FieldType.Keyword)
    private String detail;

    /**
     * 修改时间
     */
   @Field(type = FieldType.Date,format= DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
   @JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date updateTime;

    /**
     * 创建时间
     */
    @Field(type = FieldType.Date,format= DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern ="yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
    private Date createTime;

    /**
     * 商品标签
     */
    @Field(type = FieldType.Keyword)
    private String labelName;

    /**
     * 商品属性集合
     */
    @Field(type = FieldType.Object)
    private List<ProductAttribute>   attributes;

    /**
     * 商品SKU集合
     */
    @Field(type = FieldType.Object)
    private List<ProductSku> productSku;

    /**
     * 商品参数集合
     */
    @Field(type = FieldType.Object)
    private List<ProductParam> productParams;


}
